package com.catering.service.impl;

import com.catering.mapper.AppointmentMapper;
import com.catering.pojo.Appointment;
import com.catering.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppointmentServiceImpl implements AppointmentService {

    @Autowired
    private AppointmentMapper appointmentMapper;

    @Override
    public boolean checkTodayAppointment(String phone) {
        if (phone == null || phone.trim().isEmpty()) {
            return false;
        }
        Integer count = appointmentMapper.checkTodayAppointment(phone);
        return count != null && count > 0;
    }

    @Override
    public Appointment getTodayAppointment(String phone) {
        if (phone == null || phone.trim().isEmpty()) {
            return null;
        }
        return appointmentMapper.getTodayAppointment(phone);
    }

    @Override
    public Appointment getAppointmentById(Integer id) {
        if (id == null) {
            return null;
        }
        return appointmentMapper.selectByOrder(id);
    }
}
